/*    */ package com.zimbra.cs.account.ldap.upgrade;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.cs.account.Cos;
/*    */ import com.zimbra.cs.account.Entry;
/*    */ import com.zimbra.cs.account.Entry.EntryType;
/*    */ import com.zimbra.cs.account.ldap.LdapProv;
/*    */ import com.zimbra.cs.ldap.LdapClient;
/*    */ import com.zimbra.cs.ldap.LdapServerType;
/*    */ import com.zimbra.cs.ldap.LdapUsage;
/*    */ import com.zimbra.cs.ldap.ZLdapContext;
/*    */ import java.util.Arrays;
/*    */ import java.util.HashMap;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class BUG_60640
/*    */   extends UpgradeOp
/*    */ {
/* 36 */   private static final String[] ATTR_NAMES = { "zimbraPrefReadingPaneLocation", "zimbraPrefTasksReadingPaneLocation", "zimbraPrefBriefcaseReadingPaneLocation" };
/*    */   
/*    */ 
/*    */   private static final String OLD_VALUE = "bottom";
/*    */   
/*    */   private static final String NEW_VALUE = "right";
/*    */   
/*    */ 
/*    */   void doUpgrade()
/*    */     throws ServiceException
/*    */   {
/* 47 */     ZLdapContext zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.UPGRADE);
/*    */     try {
/* 49 */       doAllCos(zlc);
/*    */     } finally {
/* 51 */       LdapClient.closeContext(zlc);
/*    */     }
/*    */   }
/*    */   
/*    */   Description getDescription()
/*    */   {
/* 57 */     return new Description(this, ATTR_NAMES, new Entry.EntryType[] { Entry.EntryType.COS }, "bottom", "right", String.format("Upgrade attribute %s on all cos from \"%s\" to \"%s\"", new Object[] { Arrays.deepToString(ATTR_NAMES), "bottom", "right" }));
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   private void doEntry(ZLdapContext zlc, Entry entry)
/*    */     throws ServiceException
/*    */   {
/* 67 */     String entryName = entry.getLabel();
/*    */     
/* 69 */     this.printer.println();
/* 70 */     this.printer.println("------------------------------");
/* 71 */     this.printer.format("Checking %s on cos %s\n", new Object[] { Arrays.deepToString(ATTR_NAMES), entryName });
/*    */     
/* 73 */     Map<String, Object> attrs = new HashMap();
/* 74 */     for (String attrName : ATTR_NAMES) {
/* 75 */       String curValue = entry.getAttr(attrName, false);
/* 76 */       if ("bottom".equals(curValue)) {
/* 77 */         attrs.put(attrName, "right");
/*    */       } else {
/* 79 */         this.printer.println(String.format("    Current value of %s on cos %s is \"%s\" - not changed", new Object[] { attrName, entryName, curValue }));
/*    */       }
/*    */     }
/*    */     
/*    */ 
/*    */     try
/*    */     {
/* 86 */       modifyAttrs(zlc, entry, attrs);
/*    */     } catch (ServiceException e) {
/* 88 */       this.printer.printStackTrace(e);
/*    */     }
/*    */   }
/*    */   
/*    */   private void doAllCos(ZLdapContext zlc) throws ServiceException
/*    */   {
/* 94 */     List<Cos> coses = this.prov.getAllCos();
/* 95 */     for (Cos cos : coses) {
/* 96 */       doEntry(zlc, cos);
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/ldap/upgrade/BUG_60640.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */